package com.maker.generator.event;

import java.util.Map;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.ApplicationEvent;

import com.maker.generator.entity.MetaGenObj;
import com.maker.generator.entity.MetaGenTable;



public class GenerateEvent extends ApplicationEvent {
	private static final long serialVersionUID = -981563495509201152L;
	private static Logger logger = LoggerFactory.getLogger(GenerateEvent.class);
	
	public static final String GENERATE_TYPE_T2O ="table2Obejct";
	public static final String GENERATE_TYPE_O2M ="object2Mapper";
	public static final String GENERATE_TYPE_ENTITY ="generate_type_entity";
	public static final String GENERATE_TYPE_DAO ="generate_type_dao";
	public static final String GENERATE_TYPE_DAO_FUNCTION ="generate_type_dao_function";
	public static final String GENERATE_TYPE_CONTROLLER ="generate_type_controller";
	public static final String GENERATE_TYPE_CONTROLLER_FUNCTION ="generate_type_controller_function";
	public static final String GENERATE_TYPE_SERVICE ="generate_type_service";
	public static final String GENERATE_TYPE_SERVICE_FUNTION ="generate_type_service_function";
	public static final String GENERATE_TYPE_SERVICE_IMPL ="generate_type_service_impl";
	public static final String GENERATE_TYPE_SERVICE_IMPL_FUNCTION ="generate_type_service_impl_function";
	
	
	private String type;
	private String objectId;
	private String tableId;
	private String dbInfoId;
	private String templateDir;
	private String templateName;
	private String pageSuffix;
	private String rootOutDir;
	
	private MetaGenObj obj;
	private MetaGenTable table;
	private Map<String,Object> options;

	public GenerateEvent(Object source) {
		super(source);
		
	}
	
	public GenerateEvent(String type,MetaGenObj obj,Map<String,Object> options){
		super(type);
		this.obj = obj;
		this.options = options;
	}
	public GenerateEvent(String type,MetaGenTable table,Map<String,Object> options){
		super(type);
		this.table = table;
		this.options = options;
	}
	
	public GenerateEvent(String type,MetaGenTable table,MetaGenObj obj,Map<String,Object> options){
		super(type);
		this.table = table;
		this.obj = obj;
		this.options = options;
	}
	
	
	public GenerateEvent(String type,String objectId,String tableId,String dbInfoId,String templateDir,String templateName,String pageSuffix,String rootOutDir) {
		super(type);
		this.type = type;
		this.objectId = objectId;
		this.tableId = tableId;
		this.dbInfoId = dbInfoId;
		this.templateDir = templateDir;
		this.templateName = templateName;
		this.pageSuffix = pageSuffix;
		this.rootOutDir = rootOutDir;
		if(logger.isInfoEnabled()){
			logger.info("初始化事件【"+this.getType()+"】with id:"+this.getObjectId());
		}
	}

	public String getEventInfo(){
		
		return "";
	}
	
	public String getType() {
		return type;
	}

	public void setType(String type) {
		this.type = type;
	}

	public String getObjectId() {
		return objectId;
	}

	public void setObjectId(String objectId) {
		this.objectId = objectId;
	}

	public String getTemplateDir() {
		return templateDir;
	}

	public void setTemplateDir(String templateDir) {
		this.templateDir = templateDir;
	}

	public String getTemplateName() {
		return templateName;
	}

	public void setTemplateName(String templateName) {
		this.templateName = templateName;
	}

	public String getPageSuffix() {
		return pageSuffix;
	}

	public void setPageSuffix(String pageSuffix) {
		this.pageSuffix = pageSuffix;
	}

	public String getRootOutDir() {
		return rootOutDir;
	}

	public void setRootOutDir(String rootOutDir) {
		this.rootOutDir = rootOutDir;
	}

	public String getTableId() {
		return tableId;
	}

	public void setTableId(String tableId) {
		this.tableId = tableId;
	}

	public String getDbInfoId() {
		return dbInfoId;
	}

	public void setDbInfoId(String dbInfoId) {
		this.dbInfoId = dbInfoId;
	}

	public MetaGenObj getObj() {
		return obj;
	}

	public void setObj(MetaGenObj obj) {
		this.obj = obj;
	}

	public MetaGenTable getTable() {
		return table;
	}

	public void setTable(MetaGenTable table) {
		this.table = table;
	}

	public Map<String, Object> getOptions() {
		return options;
	}

	public void setOptions(Map<String, Object> options) {
		this.options = options;
	}
	
	
	

	

}
